package org.nanotek.persistence.jpa.base;

import java.util.List;

import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Query;

import org.nanotek.base.person.name.NamePart;
import org.nanotek.persistence.jpa.BrainzBaseDAO;

@NamedQueries(value = 	{ 	
							@NamedQuery (name = "FindByNamePart", query = "Select d from org.nanotek.base.person.name.NamePart d where d = :value") ,
							@NamedQuery(name = "FindByNamePartValue", query = "Select d from org.nanotek.base.person.name.NamePart d where d.value like concat('%',concat(:value,'%'))")
						})
public class NamePartDAO <T extends NamePart> extends BrainzBaseDAO<T>{

	
	public List<?> findByValue(String value) 
	{ 
		Query query = entityManager.createNamedQuery("FindByNamePartValue").setParameter("value", value);
		return query.getResultList();
	}
	
	public List<?> find(NamePart value) 
	{ 
		String jpql = "Select d from org.nanotek.base.person.name.NamePart d where d = :value";
		Query query = entityManager.createQuery(jpql).setParameter("value", value);
		return query.getResultList();
	}
}
